<?php
	require('includes/top.php');
?>
<script type="text/javascript" src="jquery/jquery.min.js"></script>

        <style type="text/css">
        	#lightbox{
				display:none;
        		background:#000000;
				opacity:0.9;
				filter:alpha(opacity=90);
        		position:absolute;
				top:0px;
				left:0px;
				min-width:100%;
				min-height:100%;
				z-index:1000;
        	}
			#lightbox-panel{
				display:none;
				position:fixed;
				top:20px;
				left:30%;
				margin-left:-200px;
				width:70%;
				background:#FFFFFF;
				padding:10px 15px 10px 15px;
				border:2px solid #CCCCCC;
				z-index:1001;
				height: 90%;
			}
		</style>

		<script type="text/javascript">
			$(document).ready(function(){
				$("a#close-panel").click(function(){
					$("#lightbox, #lightbox-panel").fadeOut(300);
				})
			})
		</script>

<script type="text/javascript" src="jquery/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("a#show-panel").click(function()
{	
var test=this.getAttribute('href');
var dataString = 'test='+ test;

//alert(test);
$.ajax
({
type: "POST",
url: "view_expert.php",
data: dataString,
cache: false,
success: function(html)
{

	$("#lightbox, #lightbox-panel").fadeIn(300);
	$("#lightbox-panel").html(html);
	$("#close").show();
} 
});
});

$("#lightbox").click(function()
{
	$("#lightbox, #lightbox-panel").hide();
});
								  
});
</script>
<style>
table tr th
{
	background-color:#CCC;
	padding:5px;
}
</style>
<?php
//If country and category are selected
if($_POST['con']!='0' && $_POST['cat']!='0')//query 4 both category and country selected
{
$country_id=$_POST['con'];
$category_id=$_POST['cat'];

?>
<table border="0" width="100%">
	<tr>
    	<td valign="top">
        	<table border="0">
            	<tr><th>Top Experts</th></tr>
                <?php $t=mysql_query("select * from experts where country_id=".$country_id." and expert_cat_id='1' and expert_category_id=".$category_id);				
					  while($t_res=mysql_fetch_array($t))
					  {
				?>
				<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="contactus.php"><?php echo $t_res['company_name']; ?></a><br/><?php echo $t_res['company_info']; ?><br/><?php echo $t_res['company_info']; ?><br /><div style="float:right;"><a href="contactus.php">View</a></div></div></td></tr>
				<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Listed Experts</th></tr>
                <?php $l=mysql_query("select * from experts where country_id=".$country_id." and expert_cat_id='2' and expert_category_id=".$category_id);
				  while($l_res=mysql_fetch_array($l))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel"><?php echo $l_res['company_name']; ?></a><br/><?php echo $l_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Featured Experts</th></tr>
                <?php $f=mysql_query("select * from experts where country_id=".$country_id." and expert_cat_id='3' and expert_category_id=".$category_id);
				  while($f_res=mysql_fetch_array($f))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel"><?php echo $f_res['company_name']; ?></a><br/><?php echo $f_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
    </tr>
</table>
<?php
}
//If country is selected
elseif($_POST['con']!='0' && $_POST['cat']=='0')//query 4 only country selected
{	
$country_id=$_POST['con'];
?>
<table border="0" width="100%">
	<tr>
    	<td valign="top">
        	<table border="0">
            	<tr><th>Top Experts</th></tr>
                <?php $t=mysql_query("select * from experts where country_id=".$country_id. " and expert_cat_id='1'");
					  while($t_res=mysql_fetch_array($t))
					  {
				?>
				<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="contactus.php"><?php echo $t_res['company_name']; ?></a><br/><?php echo $t_res['company_info']; ?><br/><?php echo $t_res['company_info']; ?><br /><div style="float:right;"><a href="contactus.php">View</a></div></div></td></tr>
				<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Listed Experts</th></tr>
                <?php $l=mysql_query("select * from experts where country_id=".$country_id. " and expert_cat_id='2'");
				  while($l_res=mysql_fetch_array($l))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel"><?php echo $l_res['company_name']; ?></a><br/><?php echo $l_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Featured Experts</th></tr>
                <?php $f=mysql_query("select * from experts where country_id=".$country_id. " and expert_cat_id='3'");
				  while($f_res=mysql_fetch_array($f))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel"><?php echo $f_res['company_name']; ?></a><br/><?php echo $f_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
    </tr>
</table>
<?php
}
//If category is selected
elseif($_POST['con']=='0' && $_POST['cat']!='0')//query 4 only country selected
{	
$category_id=$_POST['cat'];
?>
<table border="0" width="100%">
	<tr>
    	<td valign="top">
        	<table border="0">
            	<tr><th>Top Experts</th></tr>
                <?php $t=mysql_query("select * from experts where expert_cat_id='1' and expert_category_id=".$category_id); 
					  while($t_res=mysql_fetch_array($t))
					  {
				?>
				<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="contactus.php"><?php echo $t_res['company_name']; ?></a><br/><?php echo $t_res['company_info']; ?><br/><?php echo $t_res['company_info']; ?><br /><div style="float:right;"><a href="contactus.php">View</a></div></div></td></tr>
				<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Listed Experts</th></tr>
                <?php $l=mysql_query("select * from experts where expert_cat_id='2' and expert_category_id=".$category_id); 
				  while($l_res=mysql_fetch_array($l))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel"><?php echo $l_res['company_name']; ?></a><br/><?php echo $l_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $l_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
        <td valign="top">
        	<table border="0">
            	<tr><th>Featured Experts</th></tr>
                <?php $f=mysql_query("select * from experts where expert_cat_id='3' and expert_category_id=".$category_id); 
				  while($f_res=mysql_fetch_array($f))
				  {
			?>
			<tr><td><div style="border:1px solid #999;overflow:auto;padding:5px;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel"><?php echo $f_res['company_name']; ?></a><br/><?php echo $f_res['company_info']; ?><br /><div style="float:right;"><a href="#?<?php echo $f_res['experts_id']; ?>" id="show-panel">View</a></div></div></td></tr>
			<?php } ?>
            </table>
        </td>
    </tr>
</table>
<?php
}
?>